import http from "@/utils/http";

/**
 * @description: 获取最新的购物车列表
 * @param {*}
 * @return {*}
 */

export const findCartByIdAPI = (id) => {
    return http.get('/cart/findById', {
        params: { id }
    });
}

/**
 * @description: 根据data对象进行新增购物车
 * @param {data} 用户对象
 * @return {*}
 */
export function insertCartAPI(data){
    return http.post('/cart/addCart',data);
}

/**
 * @description: 根据id删除购物车
 * @param {*}
 * @return {*}
 */
export const delCartAPI = (userId,productId) => {
    return http.get('/cart/deleteById', {
        params: { userId,productId }
    });
}

export const delUserCartAPI = (userId) => {
    return http.get('/cart/deleteByUserId', {
        params: { userId }
    });
}

// export const delCartAPI = (ids) => {
//     return http.delete('/member/cart',{data:{ids}})
// }

//修改购物项
// export function updateCartItem(skuId,data){
//     return http.put(`/member/cart/${skuId}`,data);
// }
export function updateCartItem(data){
    return http.post('/cart/updateById',data);
}